# -*- coding: UTF-8 -*-
# Author:JackyMao
# Blog:https://blog.csdn.net/xiaokai1999
import json
import os
import sys

class PlayListParse:
    path = ""
    ids = []
    def Parse(self,platform):
        self.GetPath()
        with open(self.path+"parse.txt","r",encoding= 'utf-8') as f:
            data = f.read()
        f.close()
        json_content = json.loads(data)
        if platform == "网易云音乐":
            privileges = json_content["privileges"]
            for i in range(len(privileges)):
                if privileges[i]["st"] == 0:
                    self.ids.append(privileges[i]["id"]) 
            return self.ids
            
    def GetPath(self):
        if getattr(sys,'frozen',False):
            self.path = os.path.dirname(sys.executable)+"\\"    # 编成exe文件后的路径
        elif __file__:
            self.path = os.path.dirname(__file__)+"\\"           # py文件时的路径
